﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Web.UI;
using System.Collections;

namespace Marbles.Core.Web.Wiki
{
    public class WikiDocument
    {
        public string Markup { get {return this._Markup;} set {this._Markup=value;} }
        public string Title  { get {return this._Title;} set {this._Title=value;} }
        public string NameSpace  { get {return this._NameSpace;} set {this._NameSpace=value;} }
        public long RevisionId  { get {return this._Revisionid;} set {this._Revisionid=value;} }
        public Guid DocumentGuid {get {return this._Guid;}}

        private Guid _Guid = Guid.Empty;
        private string _Markup = string.Empty;
        private string _Title = string.Empty;
        private string _NameSpace = string.Empty;
        private long _Revisionid = 0;

        public WikiDocument(Guid DocumentGuid, string Markup, string Title, string NameSpace, long RevisionId)
        {
            if (DocumentGuid == Guid.Empty) { this._Guid = Guid.NewGuid(); } else { this._Guid = DocumentGuid; }
            this._Markup = Markup;
            this._Title = Title;
            this._NameSpace = NameSpace;
            this._Revisionid = RevisionId;
        }

        public WikiDocument(string NameSpace)
        {
            this._Guid = Guid.NewGuid();
            this._Markup = string.Empty;
            this._Title = string.Empty;
            this._NameSpace = NameSpace;
            this._Revisionid = 1;
        }
        
        internal WikiDocument(DataRow DataSource)
        {
            this._Guid = new Guid(DataSource["documentguid"].ToString());
            this._Markup = DataSource["Markup"].ToString();
            this._Title = DataSource["Title"].ToString();
            this._NameSpace = DataSource["NameSpace"].ToString();
            this._Revisionid = Convert.ToInt64(DataSource["RevisionId"]);            
        }

        internal WikiDocument(DataRowView DataSource)
        {
            this._Guid = new Guid(DataSource["documentguid"].ToString());
            this._Markup = DataSource["Markup"].ToString();
            this._Title = DataSource["Title"].ToString();
            this._NameSpace = DataSource["NameSpace"].ToString();
            this._Revisionid = Convert.ToInt64(DataSource["RevisionId"]);
        }        
    }
}
